/**
 * 用户管理-关心节日查询
 */
var followHolidayManagerGrid = function(userId,status) {
	// 定义表的每列（对应表头信息）
	var followHolidayManagerCm = new Ext.grid.ColumnModel([
			new Ext.grid.RowNumberer(), {
				dataIndex : "id",
				header : "编号",
				sortable : true,
				width : 70
			}, {
				dataIndex : "userName",
				header : "用户姓名",
				sortable : true,
				width : 70,
				renderer : function(value, meta, record) {
					if (value) {
						meta.attr = 'ext:qtitle="用户名称:" ext:qtip="' + value + '"';
						return value;
					}
				}
			}, {
				dataIndex : "title",
				header : "关注标题",
				sortable : true,
				width : 70,
				renderer : function(value, meta, record) {
					if (value) {
						meta.attr = 'ext:qtitle="用户名称:" ext:qtip="' + value + '"';
						return value;
					}
				}
			},{
				dataIndex : "sex",
				header : "性别",
				sortable : true,
				width : 100,
				renderer : function(value) {
					return PmsUtil.FollowHolidaySex(value);
				}
			},{
				dataIndex : "birthday",
				header : "出生日期",
				sortable : true,
				width : 130,
				renderer : function(date){
					return Ext.util.Format.substr(date, 0, 10);
				}
			},{
				dataIndex : "status",
				header : "状态",
				sortable : true,
				width : 70,
				renderer : function(value) {
					var value = '<div style="color:red;">'+PmsUtil.FollowHoliday(value);+'</div>';
					return value;
				}
			}, {
				dataIndex : "createdDate",
				header : "创建时间",
				sortable : true,
				width : 130
			}, {
				dataIndex : "createdName",
				header : "创建人",
				sortable : true,
				width : 60
			}, {
				dataIndex : "updatedDate",
				header : "修改时间",
				sortable : true,
				width : 130
			}, {
				dataIndex : "updatedName",
				header : "修改人",
				sortable : true,
				width : 60
			}]);

	// 定义分析器
	var followHolidayManagerReader = new Ext.data.JsonReader({
				totalProperty : "totalCount",
				root : "list",
				fields : [{
							name : "id"
						}, {
							name : "userName"
						}, {
							name : "title"
						}, {
							name : "sex"
						}, {
							name : "birthday"
						}, {
							name : "status"
						}, {
							name : "createdDate"
						}, {
							name : "createdName"
						}, {
							name : "updatedDate"
						}, {
							name : "updatedName"
						}]
			});

	// 取数据store
	var followHolidayViewStore = new Ext.data.Store({
				autoLoad : true,// 要加载数据必须设置为true
				proxy : new Ext.data.HttpProxy({
							url : __ctxPath + "/userManager/selectFollowHolidays"
						}),
				remoteSort : false,
				baseParams : {
					start : 0,
					limit : 25,
					userId:userId,
					status:status
				},
				reader : followHolidayManagerReader
			});

	
	// 定义grid的toolbar
	var followHolidayTb = new Ext.Toolbar({
				id : "followHolidayTb",
				height : 25,
				items : []
			});
	followHolidayTb.add(new Ext.scm.Button({
				text : "刷 新",
				width : 80,
				iconCls : "btn-refresh",
				hsValue : 'followHoliday_刷新',
				pressed : true,
				handler : function() {
					queryfollowHoliday();
				}
			}));
			
	var followHolidayManagerGrid = new Ext.grid.GridPanel({
				id : 'followHolidayManagerGrid',
				store : followHolidayViewStore,
				cm : followHolidayManagerCm,
				autoScroll : true,
				loadMask : true,
				stripeRows : true,
				columnLines : true,
				loadMask : {
					msg : "正在加载数据，请稍侯……"
				},
				viewConfig : {
					emptyText : '没有您想要的数据!'
				},
				anchor : '100% 100%',
				frame : true,
				tbar:followHolidayTb,
				bbar : new PG.PagingBar({
							id : 'followHolidayGridPage',
							store : followHolidayViewStore
						})
			});
	return followHolidayManagerGrid;
};

// 查询
function queryfollowHoliday() {
	var grid = Ext.getCmp("followHolidayManagerGrid");
	var store = grid.store;
	var pagesize = Ext.getCmp('followHolidayGridPage').pageSize;
	store.load({
				params : {
					start : 0,
					limit : pagesize
				}
			});
}